﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="productsList.aspx.cs" Inherits="TwoWheels.productsList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        List of Products 
    </h2>
    <br /><br />
    
    <asp:GridView HorizontalAlign="Center" ID="CategoriesView2" runat="server" AutoGenerateColumns="false" CellPadding="10" DataKeyNames="ProduktID" DataSourceID="SQLDataConnect2" ForeColor="#333333" GridLines="Both" BorderWidth="1" >
        <Columns>      
            <asp:HyperLinkField DataNavigateUrlFields="NazwaProduktu" DataNavigateUrlFormatString="~/Product.aspx?Name={0}" DataTextField="NazwaProduktu" AccessibleHeaderText="true" HeaderText="Product Name">
                <ItemStyle Width="300px"/>  
            </asp:HyperLinkField>
            <asp:BoundField DataField="CenaJednostkowa" HeaderText="Price" ReadOnly="True">
                 <ItemStyle Width="140px" HorizontalAlign="Center" />  
            </asp:BoundField>
            <asp:BoundField DataField="ProduktowWMagazynie" HeaderText="In stock" ReadOnly="True">
                 <ItemStyle Width="100px" HorizontalAlign="Center" />  
            </asp:BoundField>
            <asp:TemplateField HeaderText = "Add" Visible="false">
               <ItemTemplate>        
                   <asp:Button ID="AddButton" runat="server" 
                            CommandName="AddToCart" 
                            CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                            Text="Add to Cart"
                            OnClick="addToCart_Button" />
               </ItemTemplate> 
            </asp:TemplateField>  
        </Columns>
    </asp:GridView>
    
    <asp:SqlDataSource ID="SQLDataConnect2" runat="server" 
    ConnectionString="<%$ connectionStrings: ApplicationServices %>"
    SelectCommand="SELECT [ProduktID], [KategoriaKategoriaID], [NazwaProduktu], [CenaJednostkowa], [ProduktowWMagazynie], [Wycofany], [Zdjecie] FROM [Produkt] where [KategoriaKategoriaID] like (SELECT TOP (1) KategoriaID FROM Kategoria WHERE (NazwaKategorii LIKE @ID))"
    >   
      <SelectParameters>
        <asp:QueryStringParameter Name="ID" Type="String" QueryStringField="ID" />
      </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
